package com.demo.es.config;

/**
 * 日期时间全局配置类
 * @author : 李炯
 * @date : 2020-05-14 09:28
 **/
/*@Configuration
public class DateTimeConfig {

    *//**
     * 日期时间字符串和LocalDateTime的相互转换
     *
     * @return ObjectMapper对象
     *//*
    @Bean
    public ObjectMapper DeserializingObjectMapper() {
        // 创建java时间模型对象
        JavaTimeModule module = new JavaTimeModule();
        // 创建LocalDateTime的反序列化（解串器）对象
        LocalDateTimeDeserializer localDateTimeDeserializer =
                new LocalDateTimeDeserializer(DateTimeFormatter.ofPattern(DateTimeConstant.DATE_FORMAT_ONE));
        // 创建LocalDateTime的序列化对象
        LocalDateTimeSerializer localDateTimeSerializer =
                new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(DateTimeConstant.DATE_FORMAT_ONE));
        // 设置反序列化的转换规则，即将规定格式的字符串解析成LocalDateTime对象
        module.addDeserializer(LocalDateTime.class, localDateTimeDeserializer)
                // 设置序列化的转换规则，即将LocalDateTime对象转换成规定格式的字符串
                .addSerializer(LocalDateTime.class, localDateTimeSerializer);
        // 创建附带解串器的规则的对象ObjectMapper
        ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json()
                .modules(module)
                .featuresToDisable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
                .build();
        return objectMapper;
    }
}*/
